import { ApiCall } from "tsrpc";
import { ReqOffLine, ResOffLine } from "../../../shared/master/body/PtlOffLine";
import { player } from "../../../model/fight/body/player";
import { template } from "../../../shared/master/MsgAction";
import manage_user from "../../model/manage/manage_user";
import manage_word from "../../model/manage/manage_word";

export default async function (call: ApiCall<ReqOffLine, ResOffLine>) {
    call.succ({})
    let user = call.req._player as player;
    if(user.get_battle()){
        user.sendMsg(template.default,'你正在战斗中,无法挂机')
        return;
    }
    let _cell =  user.getPosition();
    if(_cell.getWord().id != '1'){
        await user.sendMsg(template.default,'正在回到主神空间....')
        let info = await manage_word.transfer(user,'1');
        await user.sendMsg(template.default,info.msg)
        if(!info.jude){
            return;
        }
    }
    user.sendMsg(template.default,'开始挂机,每分钟消耗🐟️小鱼干X1,挂机后你将不会再收到任何消息~')
    manage_user.offLine(user)
}